﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Batalha_Estelar
{
    class Missel : GameObject
    {
   
        #region Fields

        protected float speed;

        public Starship Ship { get; set; }

        public FieldController MyFieldController { get; set; }

        #endregion 

        #region Construtores

        public Missel(BatalhaEstelar game, Starship ship, Vector2 posicao, Vector2 direcaoMissel)
            : base(game)
        {
            Textura = game.Content.Load<Texture2D>(@"Imagens/missel");
            MyFieldController = new FieldController(game, this);
            Posicao = posicao;
            Direcao = direcaoMissel;
            speed = 700.0f;
            Ship = ship;
        }

        #endregion

        #region GameObject Methods

        public override void Update(GameTime gameTime)
        {
            var gameSpeed = MyGame.Config.GameSpeed;
            var elapsedGameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            Posicao += Direcao * speed * gameSpeed * elapsedGameTime;
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Textura, Posicao, Color.White);
        }

        public override bool CanDestroy()
        {
            //Se não estiver dentro do campo ou colidir, pode destruir
            return !MyFieldController.Within() || Colision;
        }

        protected override void Dispose(bool disposing)
        {
            //nada por enquanto...
            return;
        }

        #endregion

    }
}
